package com.xiyu.service.controller.admin.health;
import com.xiyu.service.vo.health.medicineDeposit.MedicineDepositGetElderMedicineOutput;
import com.xiyu.service.vo.health.medicineDeposit.MedicineDepositCreateInput;
import com.xiyu.service.vo.health.medicineDeposit.MedicineDepositPageQueryOutput;
import com.xiyu.service.vo.health.medicineDeposit.MedicineDepositPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.health.MedicineDepositService;

@Tag(name = "药品缴存")
@RestController
@RequestMapping("/health/medicine-deposit")
@Validated
public class MedicineDepositController {

    @Resource
    private MedicineDepositService medicineDepositService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询药品缴存")
    @PreAuthorize("@ss.hasPermission('health:medicineDeposit:query')")
    public CommonResult<PageResult<MedicineDepositPageQueryOutput>> pageQuery(@Valid MedicineDepositPageQueryInput inputVO) {
        return success(medicineDepositService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "批量创建药品缴存")
    @PreAuthorize("@ss.hasPermission('health:medicineDeposit:create')")
    public CommonResult<Boolean> create(@Valid @RequestBody List<MedicineDepositCreateInput> inputVO) {
        return success(medicineDepositService.create(inputVO));
    }

    @GetMapping("/get-elder-medicine")
    @Operation(summary = "获取单个老人的药品")
    @Parameter(name = "elderId", description = "老人ID", example = "")
    public CommonResult<List<MedicineDepositGetElderMedicineOutput>> getElderMedicine(@RequestParam("elderId") Long elderId) {
        return success(medicineDepositService.getElderMedicine(elderId));
    }

}
